﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace JungleSurvivor
{
    class EnemySpawner
    {
        int rand;
        public TimeSpan lastSpawn, timeSpent;
        public Vector2 position, tileCoordinates;
        public Rectangle area;
        public void SpawnEnemy(GameTime gameTime, ContentManager content, List<Enemy> EnemyList, Random RNG)
        {
            timeSpent += gameTime.ElapsedGameTime;
            if (timeSpent.Seconds - lastSpawn.Seconds >= 7)
            {
                Enemy enemy = new Enemy(Enemy.EnemyType.Normal, content);
                rand = RNG.Next(-1, 3);
                switch (rand)
                {
                    case 0:
                        enemy.active = false;
                        return;
                    case 1:
                        enemy = new Enemy(Enemy.EnemyType.Normal, content);
                        break;
                    case 2:
                        enemy = new Enemy(Enemy.EnemyType.Fast, content);
                        break;
                }
                    
                enemy.position = position;
                enemy.area = new Rectangle((int)enemy.position.X, (int)enemy.position.Y, 64, 64);
                EnemyList.Add(enemy);
                lastSpawn = timeSpent;
            }

        }
    }
}
